﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Arcadium.GameEntities.Characters;
using Arcadium.GameEntities.Projectiles;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Net;

namespace Arcadium.GameEntities
{
    class HostWorld : World
    {
        #region Initialization

        public override void LoadContent(ContentManager content, GameSessionProperties sessionProperties)
        {
            base.LoadContent(content, sessionProperties);
            AddEntity(new Crate(this));
        }

        #endregion

        #region Update

        /// <summary>
        /// Called only by the host. Spawns enemies, adds to sendingqueue. Update existing list of entities.
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            double enemySpawn = random.NextDouble();
            if (enemySpawn < .005)
            {
                int direction = random.NextDouble() < .5 ? 1 : -1;
                //if (enemySpawn < .0005)
                //    AddEntity(BigEnemyCharacter.Crate(this, direction));
                //else
                    AddEntity(SmallEnemyCharacter.Create(this, direction));
            }
        }
        
        #endregion

        //public override void ReadProjectile(Microsoft.Xna.Framework.Net.PacketReader packetReader, Microsoft.Xna.Framework.Net.NetworkGamer shooter)
        //{
        //    Projectile projectile;
        //    byte projectileType = packetReader.ReadByte();
        //    //if (projectileType == 0)
        //    projectile = new StandardBullet(this, shooter, packetReader.ReadVector2(), packetReader.ReadVector2());
        //    //else if (projectileType  == 1)
        //    //    projectile = new Missile(...
        //    AddEntity(projectile);
        //}

        //public override void ReadEnemy(Microsoft.Xna.Framework.Net.PacketReader packetReader)
        //{
        //    Character enemy;
        //    byte enemyType = packetReader.ReadByte();
        //    if (enemyType == 0)
        //        enemy = new SmallEnemyCharacter(this, packetReader.ReadBoolean() ? 1 : -1);
        //    else //if (enemyType == 1)
        //        enemy = new BigEnemyCharacter(this, packetReader.ReadBoolean() ? 1 : -1);
        //}


    }
}
